#include "MemoryReaderWin.h"

#include <Windows.h>

#include <iostream>

bool MemoryReaderWin::read_( address_t address, size_t size, unsigned char* buf ) const
{
	DWORD actually_read = 0;
	if (!::ReadProcessMemory(handle.get(), (LPCVOID)address, buf, size, &actually_read))
	{
		std::cout << "Error while reading process Memory: " << GetLastError() << std::endl;
		return false;
	}
	if (actually_read != size)
	{
		std::cout << "Read " << actually_read << " instead of " << size << " bytes!";
		return false;
	}
	return true;
}

MemoryReaderWin::MemoryReaderWin( process_handle hndl ) : handle(hndl)
{

}

